build:
	go build -ldflags="-s -w" goctl.go
	$(if $(shell command -v upx), upx goctl)

mac:
	GOOS=darwin go build -ldflags="-s -w" -o goctl-darwin goctl.go
	$(if $(shell command -v upx), upx goctl-darwin)

win:
	go build -o D:\project\go\bin\goctl.exe
linux:
	GOOS=linux go build -ldflags="-s -w" -o /usr/local/bin/goctl-gin-linux goctl.go
	$(if $(shell command -v upx), upx goctl-linux)
	chmod +x  /usr/local/bin/goctl-gin-linux

image:
	docker build --rm --platform linux/amd64 -t kevinwan/goctl:$(version) .
	docker tag kevinwan/goctl:$(version) kevinwan/goctl:latest
	docker push kevinwan/goctl:$(version)
	docker push kevinwan/goctl:latest
	docker build --rm --platform linux/arm64 -t kevinwan/goctl:$(version)-arm64 .
	docker tag kevinwan/goctl:$(version)-arm64 kevinwan/goctl:latest-arm64
	docker push kevinwan/goctl:$(version)-arm64
	docker push kevinwan/goctl:latest-arm64

gen-build-win:
	go env -w GOOS=windows
	go build -o goctl-gin.exe goctl.go
	go env -w GOOS=darwin
	go build -o goctl-gin-darwin goctl.go
	go env -w GOOS=linux
	go build -o goctl-gin-linux goctl.go
	go env -w GOOS=windows

